package com.dpiinc.TechPage.room.dao
import androidx.room.*
import com.dpiinc.TechPage.oss.UploadTask


@Dao
interface UploadTaskDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insert(task: UploadTask)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insert(tasks: List<UploadTask>)

    @Query("SELECT * FROM upload_task WHERE noteId = :noteId ")
    fun getTasksById(noteId: String): List<UploadTask>

    @Query("SELECT * FROM upload_task WHERE noteId = :noteId AND fileType = :type")
    fun getCacheFilesByType(noteId: String, type: Int): List<UploadTask>

    @Update
    fun update(task: UploadTask)

    @Delete
    fun delete(task: UploadTask)

    @Query("DELETE FROM upload_task")
    fun deleteAll()

    @Query("DELETE FROM upload_task WHERE noteId = :noteId ")
    fun deleteById(noteId: String)

    @Query("UPDATE upload_task SET noteId = :destNoteId WHERE noteId = :srcNoteId")
    fun updateNoteId(srcNoteId: String, destNoteId: String)

}